// ** Third Party Components
import axios from 'axios'
import { FileText } from 'react-feather'
import { UncontrolledTooltip } from 'reactstrap'

export let data

// ** Get initial Data
data = [
  {
    id: '1',
    name: '数据状态',
    type: 'data_status',
    status: '正常',
    remark: '数据列表',
  },
  {
    id: '2',
    name: '菜单状态',
    status: '正常',
    remark: '菜单列表',
    type: 'menu_status',
  },
  {
    id: '3',
    name: '质量等级',
    status: '正常',
    remark: '产出物列表',
    type: 'quality_level',
  },
  {
    id: '4',
    name: '设备状态',
    status: '正常',
    remark: '设备列表',
    type: 'equip_level',
  },
]

const statusEnum = {
  0: '#ea5455',
  1: '#56affd',
}
// ** Table Common Column
export const columns = (handleEdit, handleDelete) => [
  {
    name: '字典编号',
    minWidth: '100px',
    cell: (row) => row._id.slice(0, 5),
  },
  {
    name: '字典名称',
    minWidth: '150px',
    selector: (row) => row.name,
  },
  {
    name: '字典类型',
    minWidth: '150px',
    selector: (row) => row.type,
  },
  {
    name: '状态',
    minWidth: '150px',
    cell: (row) => (
      <span
        style={{
          color: statusEnum[row.status.value],
          border: `1px solid ${statusEnum[row.status.value]}`,
          borderRadius: '4px',
          padding: '1px 4px',
        }}
      >
        {row.status.label}
      </span>
    ),
  },
  {
    name: '备注',
    minWidth: '150px',
    selector: (row) => row.remark,
  },
  {
    name: '操作',
    width: '200px',
    selector: (row) => (
      <div
        className="column-action d-flex align-items-center"
        style={{ color: '#7367f0' }}
      >
        <div
          className="ms-50 cursor-pointer"
          onClick={() => {
            handleEdit(row._id)
          }}
        >
          编辑
        </div>
        <div
          className="ms-50 cursor-pointer"
          onClick={() => {
            handleDelete(row._id)
          }}
        >
          删除
        </div>
      </div>
    ),
  },
]
